package ar.camera.renderer.base;

import java.util.List;

import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;

import android.content.Context;
import android.opengl.GLSurfaceView.Renderer;
import ar.camera.pojo.GLPoint;
import ar.camera.pojo.GeoLocation;

public class BaseRenderer implements Renderer {

	protected Context mContext;
	protected GLPoint eye;
	protected GLPoint cam;
	protected GeoLocation mMyCurrentGeoLocation;
	protected List<GeoLocation> mListOfGeoLocations;
	protected float ratio;

	public GeoLocation getmMyCurrentGeoLocation() {
		return mMyCurrentGeoLocation;
	}

	public void setmMyCurrentGeoLocation(GeoLocation mMyCurrentGeoLocation) {
		this.mMyCurrentGeoLocation = mMyCurrentGeoLocation;
	}

	public void setmListOfGeoLocations(List<GeoLocation> mListOfGeoLocations) {
		this.mListOfGeoLocations = mListOfGeoLocations;
	}

	public List<GeoLocation> getmListOfGeoLocations() {
		return mListOfGeoLocations;
	}

	public void setEye(GLPoint eye) {
		this.eye = eye;
	}

	public void setCam(GLPoint cam) {
		this.cam = cam;
	}

	public GLPoint getEye() {
		return eye;
	}

	public GLPoint getCam() {
		return cam;
	}

	public BaseRenderer(Context mContext, GLPoint eye, GLPoint cam) {
		super();
		this.mContext = mContext;
		this.eye = eye;
		this.cam = cam;
		this.ratio = (float) 800 / 480;
	}

	@Override
	public void onDrawFrame(GL10 gl) {
		gl.glClear(GL10.GL_COLOR_BUFFER_BIT | GL10.GL_DEPTH_BUFFER_BIT);

		gl.glMatrixMode(GL10.GL_MODELVIEW);
		gl.glLoadIdentity();
	}

	@Override
	public void onSurfaceChanged(GL10 gl, int width, int height) {
		if (height == 0) { 
			height = 1; 
		}
		gl.glEnable(GL10.GL_TEXTURE_2D);
		gl.glViewport(0, 0, width, height);
		// child
	}

	@Override
	public void onSurfaceCreated(GL10 gl, EGLConfig config) {     
        
		gl.glEnable(GL10.GL_TEXTURE_2D); 
		gl.glShadeModel(GL10.GL_SMOOTH); 
		gl.glClearDepthf(1.0f);
		gl.glEnable(GL10.GL_DEPTH_TEST);
		gl.glDepthFunc(GL10.GL_LEQUAL);

		gl.glHint(GL10.GL_PERSPECTIVE_CORRECTION_HINT, GL10.GL_NICEST);
	}

	public void updateVertices(float azimut, GLPoint eye, GLPoint cam) {
		return;
	}
}
